package kr.totalcall.controls.dataGridClasses
{
	import mx.collections.IList;
	import mx.controls.dataGridClasses.DataGridColumn;
	import mx.core.mx_internal;
	
	use namespace mx_internal;
	
	public class RowIndexColumn extends DataGridColumn
	{
		public function RowIndexColumn(columnName:String=null)
		{
			super(columnName);
			width = 20;
			labelFunction = rowIndexLabelFunc;
		}
		
		
		protected function rowIndexLabelFunc(obj:Object, col:Object):String{
			var dataProvider : IList = owner.dataProvider as IList;
			if(!obj || !col || !dataProvider || dataProvider.length == 0) return "";
			
			var idx:int = IList(dataProvider).getItemIndex(obj) +1;
			/*
			// 컬럼 사이즈 조정.
			//if(idx == dataProvider.length){
				var colWidth:int = 4 + (idx.toString().length * 10) + 4;
				width = colWidth;
				owner.invalidateDisplayList();
			//}
			*/
			return idx.toString();
		}
	}
}